From a64dfb1dfcff195b5aa2c17819b15cb1471bafbf Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 2 Jun 2019 19:42:14 +0000 Subject: [PATCH] gl: Make the glyph cache survive big glyphs Create an extra atlas of just the right size for each huge glyph. Not pretty, but works. --- gsk/gl/gskglglyphcache.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gsk/gl/gskglglyphcache.c b/gsk/gl/gskglglyphcache.c index 208ca28e87..d540d76c1e 100644 --- a/gsk/gl/gskglglyphcache.c +++ b/gsk/gl/gskglglyphcache.c @@ -33,13 +33,15 @@ static void glyph_cache_key_free (gpointer v); static void glyph_cache_value_free (gpointer v); static GskGLGlyphAtlas * -create_atlas (GskGLGlyphCache *cache) +create_atlas (GskGLGlyphCache *cache, + int width, + int height) { GskGLGlyphAtlas *atlas; atlas = g_new0 (GskGLGlyphAtlas, 1); - atlas->width = ATLAS_SIZE; - atlas->height = ATLAS_SIZE; + atlas->width = MAX (width, ATLAS_SIZE); + atlas->height = MAX (height, ATLAS_SIZE); atlas->y0 = 1; atlas->y = 1; atlas->x = 1; @@ -70,7 +72,6 @@ gsk_gl_glyph_cache_init (GskGLGlyphCache *self, self->hash_table = g_hash_table_new_full (glyph_cache_hash, glyph_cache_equal, glyph_cache_key_free, glyph_cache_value_free); self->atlases = g_ptr_array_new_with_free_func (free_atlas); - g_ptr_array_add (self->atlases, create_atlas (self)); self->renderer = renderer; self->gl_driver = gl_driver; @@ -167,7 +168,7 @@ add_to_cache (GskGLGlyphCache *cache, if (i == cache->atlases->len) { - atlas = create_atlas (cache); + atlas = create_atlas (cache, width + 2, height + 2); g_ptr_array_add (cache->atlases, atlas); } @@ -223,7 +224,7 @@ render_glyph (const GskGLGlyphAtlas *atlas, /* TODO: Give glyphs that large their own texture in the proper size. Don't * put them in the atlas at all. */ - if (surface_width > ATLAS_SIZE || surface_height > ATLAS_SIZE) + if (surface_width > atlas->width || surface_height > atlas->height) return FALSE; surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, surface_width, surface_height); -- 2.30.2